class MapBook {
    constructor() {
        //初始化插件
        this.plugins = new Array();
    }

    setBook(book) {
        //初始化书籍
        this.book = book;
        this.book.mountMapBook(this);
    }

    setMapLoader(mapLoader) {
        mapLoader.mountMapBook(this);
        this.mapLoader = mapLoader;
    }

    installPlugin(plugin) {
        plugin.mountMapBook(this);
        this.plugins.push(plugin);
    }

    //加载书籍内容
    loadBook(mapContainer, bookContainer, config) {
        var that = this;
        this.config = config;
        //地图加载器加载地图元素
        this.mapLoader.loadMap(mapContainer, config.map);
        this.book.loadBook(bookContainer, config.book);
        //执行地图加载成功后的回调
        this.map.on("load", function () {
            //页面版式加载故事
            that.book.onMapLoaded();
            that.plugins.forEach((plugin) => {
                if (plugin.onMapLoaded) {
                    plugin.onMapLoaded();
                }
            });
        });
    }

    nextPage()
    {

    }

    prePage()
    {

    }

    gotoPage(page)
    {
        this.book.gotoPage(page);
    }
}